#include "widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
{
    QLineEdit * linedit= new QLineEdit("水平布局");
    QPushButton *btn= new QPushButton("这是一个按钮");
    QHBoxLayout *hbox = new QHBoxLayout;
    hbox->addWidget(linedit);
    hbox->addWidget(btn);
    connect(btn,&QPushButton::clicked,[&](){
        QWidget * widget= new QWidget();
        widget->setWindowTitle("提示");
        widget->resize(200,200);
        QLabel * label = new QLabel("按钮被触发了",widget);
        label->setAlignment(Qt::AlignCenter);
        QVBoxLayout *vbox = new QVBoxLayout(widget);
        vbox->addWidget(label);
        widget->show();
    });
    this->setLayout(hbox);
}

Widget::~Widget()
{
}

